package com.recruit.recommend.controller;


import com.recruit.common.model.result.PositionResultDO;
import com.recruit.recommend.service.RecommendService;
import io.github.talelin.autoconfigure.exception.NotFoundException;
import io.github.talelin.core.annotation.PermissionModule;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;


@RestController
@RequestMapping("/recruit/recommend")
@PermissionModule(value = "职位")

public class RecommendController {

    @Autowired
    private RecommendService recommendService;

    /**
     * 根据职位浏览量,热度等，进行职位推荐，详情页3个
     * @return
     */
    @GetMapping("/positionList")
    public List<PositionResultDO> recommendThree() {
        List<PositionResultDO> positionResultDOS = recommendService.recommend(3);
        if (positionResultDOS == null || positionResultDOS.size() == 0) {
            throw new NotFoundException(41000);
        }
        return positionResultDOS;
    }

    /**
     * 首页，进行职位推荐，6个
     * @return
     */
    @GetMapping("/home/positionList")
    public List<PositionResultDO> recommendSix() {
        List<PositionResultDO> positionResultDOS = recommendService.recommend(6);
        if (positionResultDOS == null || positionResultDOS.size() == 0) {
            throw new NotFoundException(41000);
        }
        return positionResultDOS;
    }
}
